// import pinia from '@/store'

// import {useTokenStore} from '@/store/modules/project'

import { requestCancel } from '@/http/cancelRequest'

// const whiteRouteList = ['/login']
// function isWhiteList(path: string) {
//   return whiteRouteList.some((i) => i === path)
// }

// let isAddRoute = false

// const store =  useTokenStore(pinia) // 如果不传入pinia，则放入守卫者中
// function getToken() {
//   return store.token
// }
export default async function routerBeforeEach(
  to: any,
  _from: any,
  next,
  _$router: any
) {
  if (to.meta.title) {
    document.title = `${to.meta.title || ''}`
  }

  requestCancel()
  next()
  // const token = getToken()
  // if (isWhiteList(to.path)) {
  //   next()
  // } else if (token) {
  //     next()
  // } else {
  //   next('/login')
  // }
}

export function resetIsAddRoute() {
  // isAddRoute = false
}
